using Microsoft.Practices.Unity;
using UnityDemo.LoggingUtility;
using UnityProvider;

namespace UnityDemo.DemoCode.AutomaticFactory
{
    internal class AutomaticFactoryDemoOld
    {
        public AutomaticFactoryDemoOld()
        {
            LogerInstance.Logger.Info("Initialized AutomaticFactoryDemoOld");
            UnityInstanceProvider.ApplicationWideUnityInstance.RegisterType<IServiceConsumer, ServiceConsumer>()
                .RegisterType<IServiceProvider, ServiceProvider>();
            var instance = UnityInstanceProvider.ApplicationWideUnityInstance.Resolve<IServiceConsumer>();
            instance.DoSomething();
        }

        internal class ServiceConsumer : IServiceConsumer
        {
            private readonly IServiceProvider _resource;

            public ServiceConsumer(IServiceProvider resource)
            {
                LogerInstance.Logger.Info("Initialized TestService");
                _resource = resource;
            }

            public void DoSomething()
            {
                LogerInstance.Logger.Info(" Started doing something ");
                _resource.GetEmployeeNames();
            }

            public void DoSomethingElse()
            {
                // NB _resource is not used in this method        // ...
            }
        }
    }
}